import UIKit
import Flutter

@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
  override func application(
    _ application: UIApplication,
    didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
  ) -> Bool {
    
    
    GeneratedPluginRegistrant.register(with: self)
    CustomNativeViewPlugin.registerWith(registry: self)
    
    
    let controller = self.window.rootViewController as! FlutterViewController
    let channel = FlutterMethodChannel(name: "zl_call", binaryMessenger: controller.binaryMessenger)
    channel.setMethodCallHandler { (methodcall, result) in
        if(methodcall.method == "show"){
            let arg = methodcall.arguments as! [String: String]
            let alertvc = UIAlertController(title: "提示", message: arg["msg"], preferredStyle: .alert)
            let action = UIAlertAction(title: "确定", style: .cancel, handler: nil)
            alertvc.addAction(action)
            controller.present(alertvc, animated: true, completion: nil)
        }
    }
    
    // 注册原生视图
    
    return super.application(application, didFinishLaunchingWithOptions: launchOptions)
  }
}
